# -*- coding: utf-8 -*-
from Products.ATContentTypes.interfaces.image import IATImage
from Products.Archetypes.public import BooleanField, StringField
from Products.Archetypes.public import BooleanWidget, StringWidget
from archetypes.schemaextender.field import ExtensionField
from archetypes.schemaextender.interfaces import ISchemaExtender
from zope.component import adapts
from zope.interface import implements


class MyBooleanField(ExtensionField, BooleanField):
    """A BooleanField field."""


class MyStringField(ExtensionField, StringField):
    """A StringField field."""


class ImageExtender(object):
    adapts(IATImage)
    implements(ISchemaExtender)

    fields = [
        MyStringField(
            'redirect',
            required=0,
            searchable=0,
            widget=StringWidget(
                description="Fournissez le lien de redirection sur l\'image.",
                label="URL"),
            validators=('isURL')),
        MyBooleanField(
            'displayedincarousel',
            required=0,
            searchable=0,
            widget=BooleanWidget(
                label="Afficher l'image dans le carrousel."))
    ]

    def __init__(self, context):
        self.context = context

    def getFields(self):
        return self.fields
